<template>
	<view>
		<view class="header">
			<view class="header-left">
				<image src="/static/back.png" @click="back" />
				<view class="header-title">
					对话列表
				</view>
			</view>
		</view>

		<!-- 对话列表 -->
		<view class="chatList">

			<view class="chatListItem" style="background-color:rgba(48, 184, 156, 0.15)" v-for="(item,index) in list"
				:key="index" @click="goDetail(item)">
				<image src="/static/ai.png" />
				<view class="chat-content">
					<view class="createTime">
						<view class="time">
							{{item.date}}
						</view>
					</view>
					<view class="createContent" style="color:rgba(48, 184, 156, 1)">
						{{item.content}}
					</view>
				</view>
			</view>

			<!-- 			<navigator class="chatListItem" style="background-color:rgba(42, 130, 228, 0.15)" wx:key="index"
				url="../AiChat/AiChat?chat_id=">
				<image src="/static/ai.png" />
				<view class="chat-content">
					<view class="createTime">
						<view class="time">
							2023
						</view>
					</view>
					<view class="createContent" style="color:rgba(42, 130, 228, 1)">
						飒飒是发
					</view>
				</view>
			</navigator> -->

		</view>

		<navigator class="addchat" url="../aiMake/aiMake">
			<image src="/static/add_black.png" />
			<view>创建新对话</view>
		</navigator>

		<!-- 悬浮按钮 -->
		<navigator class="add" url="../aiMake/aiMake">
			<image src="/static/add.png" />
		</navigator>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				params: {
					uid: ''
				},
				list: []
			}
		},
		onShow() {
			let uid = uni.getStorageSync('uid');
			this.params.uid = uid
			uni.request({
				url: 'http://localhost:3031/getChatList',
				data: this.params,
				method: 'POST',
				success: (res) => {
					console.log(res.data.data);
					this.list = res.data.data
				},
				fail: (err) => {
					console.log(err)
				}
			})
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			goDetail(item) {
				// console.log(item);
				uni.navigateTo({
					url: `../aiChat/aiChat?chat_id=${item.chatid}`
				});
			}
		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}

	.header {
		display: flex;
		justify-content: space-between;
		height: 100rpx;
		align-items: center;
		width: 100%;
	}

	.header-left {
		display: flex;
		align-items: center;
		padding-left: 30rpx;
	}

	.header-title {
		font-size: 32rpx;
		margin-left: 10rpx;
	}

	.header image {
		width: 45rpx;
		height: 45rpx;
		padding: 10rpx;
	}

	.chatList {
		padding: 0rpx 30rpx 30rpx 30rpx;
	}

	.block {
		height: 180rpx;
		background-color: #eeeeeedc;
		padding: 35rpx 30rpx;
		margin-top: 30rpx;
		align-items: center;
		border-radius: 12rpx;
	}

	.chatListItem {
		display: flex;
		justify-items: center;
		padding: 35rpx 30rpx;
		margin-top: 30rpx;
		align-items: center;
		border-radius: 12rpx;
	}

	.chatListItem>image {
		width: 100rpx;
		height: 100rpx;
		margin: 0 10rpx;
	}

	.createTime {
		display: flex;
		color: rgba(81, 81, 81, 0.712);
	}

	.chat-content {
		flex: 1;
		margin-left: 25rpx;
	}

	.createTime .time {
		/* margin-left: 5rpx; */
		font-size: 30rpx;
	}

	.createTime image {
		width: 50rpx;
		height: 50rpx;
		vertical-align: middle;
	}

	.createContent {
		margin-top: 15rpx;
		color: rgba(48, 184, 156, 1);
		font-weight: 700;
		font-size: 32rpx;
	}

	.addchat {
		display: flex;
		justify-content: center;
		background-color: rgba(0, 0, 0, 0.05);
		margin: 30rpx;
		padding: 30rpx;
		color: rgba(0, 0, 0, 0.66);
		border-radius: 10rpx;
		font-size: 31rpx;
	}

	.addchat>image {
		width: 45rpx;
		height: 45rpx;
		margin-right: 30rpx;
	}


	/* 悬浮按钮 */

	.add {
		position: fixed;
		display: flex;
		justify-content: center;
		align-items: center;
		bottom: 70rpx;
		right: 50rpx;
		height: 110rpx;
		width: 110rpx;
		text-align: center;
		/* background-color: #30b89c; */
		border-radius: 50%;
		background: linear-gradient(130.4deg, rgba(68, 212, 183, 1) 0%, rgba(48, 184, 156, 1) 100%);
		box-shadow: 0px 2px 10px 1px rgba(48, 184, 156, 0.25);
	}

	.add image {
		width: 55rpx;
		height: 55rpx;
	}


	/* 弹出层 */

	.popup-content {
		padding: 40rpx;
	}

	.popup-header {
		display: flex;
		height: 80rpx;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.06);
		padding-bottom: 15rpx;
	}

	.popup-header-title {
		font-size: 35rpx;
		font-weight: 600;
	}

	.notice-content {
		margin: 40rpx 0;
		font-size: 34rpx;
	}

	.popupTnput {
		z-index: 99;
		padding: 30rpx 0;
		/* margin: 0rpx 50rpx; */
		border-radius: 5px;
		min-height: 50vh;
		font-size: 32rpx;
		background: rgba(204, 204, 204, 0.22);
	}

	.popup-header image {
		width: 45rpx;
		height: 45rpx;
		padding: 10rpx;
	}

	.deleteMessage {
		width: 100%;
		height: 110rpx;
		line-height: 110rpx;
		color: #fff;
		font-size: 32rpx;
		text-align: center;
		border-radius: 15px;
		background: rgba(48, 184, 156, 1);
	}
</style>